<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .biaoti{
            background-color: green;
            color: red;
        }
    </style>
</head>
<body>
    <h1 class="biaoti">标题1</h1>
    <script>
        var biaoti = document.getElementsByClassName('biaoti')[0];
        biaoti.onclick = function(){
            alert('您点击了标题')
        }
    </script>
</body>
</html>

